//
// Created by Castle on 2025/10/21.
//

#include <iostream>

const unsigned char mask_bit_0 {0b00000001};
const unsigned char mask_bit_1 {0b00000010};
const unsigned char mask_bit_2 {0b00000100};
const unsigned char mask_bit_3 {0b00001000};
const unsigned char mask_bit_4 {0b00010000};
const unsigned char mask_bit_5 {0b00100000};
const unsigned char mask_bit_6 {0b01000000};
const unsigned char mask_bit_7 {0b10000000};

void use_options_v1(bool flag0,bool flag1,bool flag2,bool flag3,
    bool flag4,bool flag5,bool flag6,bool flag7) {
    std::cout << "Flags 0 is: " << flag0 << ", do something with it." << std::endl;
    std::cout << "Flags 1 is: " << flag1 << ", do something with it." << std::endl;
    std::cout << "Flags 2 is: " << flag2 << ", do something with it." << std::endl;
    std::cout << "Flags 3 is: " << flag3 << ", do something with it." << std::endl;
    std::cout << "Flags 4 is: " << flag4 << ", do something with it." << std::endl;
    std::cout << "Flags 5 is: " << flag5 << ", do something with it." << std::endl;
    std::cout << "Flags 6 is: " << flag6 << ", do something with it." << std::endl;
    std::cout << "Flags 7 is: " << flag7 << ", do something with it." << std::endl;

}

void use_options_v2(unsigned char flags) {
    std::cout << "bit0 is:" << ((flags & mask_bit_0) >> 0) << ", do something with it!" << std::endl;
    std::cout << "bit1 is:" << ((flags & mask_bit_1) >> 1) << ", do something with it!" << std::endl;
    std::cout << "bit2 is:" << ((flags & mask_bit_2) >> 2) << ", do something with it!" << std::endl;
    std::cout << "bit3 is:" << ((flags & mask_bit_3) >> 3) << ", do something with it!" << std::endl;
    std::cout << "bit4 is:" << ((flags & mask_bit_4) >> 4) << ", do something with it!" << std::endl;
    std::cout << "bit5 is:" << ((flags & mask_bit_5) >> 5) << ", do something with it!" << std::endl;
    std::cout << "bit6 is:" << ((flags & mask_bit_6) >> 6) << ", do something with it!" << std::endl;
    std::cout << "bit7 is:" << ((flags & mask_bit_7) >> 7) << ", do something with it!" << std::endl;

}


int main() {

    use_options_v1(0,0,1,1,1,0,1,0);

    std::cout << "---------------" << std::endl;

    use_options_v2(mask_bit_2 | mask_bit_4 | mask_bit_5);

    return 0;
}